<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1">
    <title th:if="${a eq 1}">添加订单</title>
    <title th:each="purchaseOrder:${purchaseOrder}">修改订单</title>
    <link rel="shortcut icon" th:href="@{/pages/logo-1.ico}" href="../static/pages/logo-1.ico"/>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" href="../static/layui/css/layui.css">
    <link rel="stylesheet" th:href="@{/layui/css/admin.css}" href="../static/layui/css/admin.css">
    <link rel="stylesheet" th:href="@{/layui/css/log.css}" href="../static/layui/css/log.css">
</head>
<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
        <div th:each="purchaseOrder:${purchaseOrder}" class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class=" layadmin-user-login-header">
                <h2>修改订单</h2>
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input th:value="${purchaseOrder.id}" type="text" readonly name="id" id="id" lay-verify="required" placeholder="修改订单ID" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input th:value="${purchaseOrder.goodsId}" type="text" name="goodsId" id="goodsId" lay-verify="required" placeholder="商品ID" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input th:value="${purchaseOrder.suppliersId}" type="text" name="supplierId" id="supplierId" lay-verify="required" placeholder="供应商ID" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input th:value="${purchaseOrder.pay}" type="text" name="name" id="pay" lay-verify="required" placeholder="支付方式" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                    <input th:value="${purchaseOrder.inDate}" type="text" class="layui-input" id="date" placeholder="时间">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input th:value="${purchaseOrder.count}"  type="text" name="count" id="count" lay-verify="required" placeholder="数量" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input th:value="${purchaseOrder.total}"  type="text" name="space" id="total" lay-verify="required" placeholder="总金额" class="layui-input">
            </div>
            <div class="layui-form-item">
                <select name="modules" id="flag" lay-verify="required" lay-search="">
                    <option value="">是否已入库</option>
                    <option value="未入库">未入库</option>
                    <option value="已入库">已入库</option>
                </select>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit" onclick="submit();" id="addpurlog">确认</button>
            </div>
            <div class="layui-form-item">
                <a href="javascript:history.go(-1);" lay-filter="LAY-user-login-submit" class="layui-btn layui-btn-fluid"  id="out">取消</a>
            </div>
        </div>

        <!-- -->
        <div  class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class=" layadmin-user-login-header">
                <h2>添加订单</h2>
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="goodsId" id="goodsId" lay-verify="required" placeholder="商品ID" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" name="supplierId" id="supplierId" lay-verify="required" placeholder="供应商ID" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" id="pay" lay-verify="required" placeholder="支付方式" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input type="text" class="layui-input" id="date" placeholder="时间">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input  type="text" name="count" id="count" lay-verify="required" placeholder="数量" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-edit"></label>
                <input  type="text" name="space" id="total" lay-verify="required" placeholder="总金额" class="layui-input">
            </div>
            <div class="layui-form-item">
                <select  name="modules" id="flag" lay-verify="required" lay-search="">
                    <option value="">是否已入库</option>
                    <option value="未入库">未入库</option>
                    <option value="已入库">已入库</option>
                </select>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit" onclick="submit();" id="addpurlog">确认</button>
            </div>
            <div class="layui-form-item">
                <a href="javascript:history.go(-1);" lay-filter="LAY-user-login-submit" class="layui-btn layui-btn-fluid"  id="out">取消</a>
            </div>
        </div>
    </div>
</div>
<script src="../static/layui/layui.js" th:src="@{/layui/layui.js}" type="text/javascript"></script>
<script src="../static/layui/data.js" th:src="@{/layui/data.js}"></script>
<script src="../static/js/vue.min.js" th:src="@{/js/vue.min.js}" type="text/javascript"></script>
<script src="../static/js/jquery-3.6.3.min.js" th:src="@{/js/jquery-3.6.3.min.js}" type="text/javascript"></script>
<script th:inline="javascript">
    //Javascript代码区域
    // window.onload=function() {
    //     let user = [[${user}]];
    //     if (user == null || user == 0) {
    //         window.location.href = "/";
    //     }
    // }

    function submit(){
        let id = $('#id').val()
        let goodsId = $('#goodsId').val()
        let supplierId = $('#supplierId').val()
        let pay = $('#pay').val()
        let date = $('#date').val()
        let count = $('#count').val()
        let total = $('#total').val()
        let flag = $('#flag').val()
        $.ajax({
            url:"/pur/addddzc",
            data:{
                id:id,
                goodsId:goodsId,
                supplierId:supplierId,
                pay:pay,
                date:date,
                count:count,
                total:total,
                flag:flag
            },
            type:"post",
            dataType :"json",
            // cache : false,
            // async : false,//设置同步（ajax请求此处需求为跳转而不是局部页面刷新）
            success:function (ddadd){
                if (ddadd==100) {
                    window.location.href = "/pur/purcgdd";
                }else if (ddadd==200) {
                    layer.open({
                        title: ''
                        , content: '请确认商品ID、供应商ID与商品表、供应商表中对应，如有疑问请及时联系管理员!'
                    });
                }
            }
        })
    }

</script>
</body>
</html>
